import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:shenfuhui/pages/asset_general_detail.dart';
import 'package:shenfuhui/pages/asset_gold_detail.dart';
import 'package:shenfuhui/pages/asset_packge.dart';
import 'package:shenfuhui/pages/home_page.dart';
import 'package:shenfuhui/pages/login_page.dart';
import 'package:shenfuhui/pages/mall_home.dart';
import 'package:shenfuhui/pages/mine_about.dart';
import 'package:shenfuhui/pages/mine_account_safety.dart';
import 'package:shenfuhui/pages/mine_address_choose.dart';
import 'package:shenfuhui/pages/mine_address_edite.dart';
import 'package:shenfuhui/pages/mine_address_manager.dart';
import 'package:shenfuhui/pages/mine_announcement.dart';
import 'package:shenfuhui/pages/mine_asset_exchange.dart';
import 'package:shenfuhui/pages/mine_change_mobile.dart';
import 'package:shenfuhui/pages/mine_change_nickname.dart';
import 'package:shenfuhui/pages/mine_change_password.dart';
import 'package:shenfuhui/pages/mine_collect_page.dart';
import 'package:shenfuhui/pages/mine_find_password.dart';
import 'package:shenfuhui/pages/mine_info.dart';
import 'package:shenfuhui/pages/mine_setting.dart';
import 'package:shenfuhui/pages/mine_share_card.dart';
import 'package:shenfuhui/pages/mine_team.dart';
import 'package:shenfuhui/pages/order_cashier.dart';
import 'package:shenfuhui/pages/order_confirm_page.dart';
import 'package:shenfuhui/pages/order_detail_page.dart';
import 'package:shenfuhui/pages/order_index.dart';
import 'package:shenfuhui/pages/product_classify.dart';
import 'package:shenfuhui/pages/product_detail_page.dart';
import 'package:shenfuhui/pages/product_list.dart';
import 'package:shenfuhui/pages/product_special_area.dart';
import 'package:shenfuhui/pages/register_page.dart';
import 'package:shenfuhui/pages/web_view.dart';

import '../pages/mine_asset_transition.dart';
import '../pages/photo_view.dart';

///
/// fluro路由的跳转动作封装
///

// 跳转首页
Handler homePageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const HomePage();
});

// 跳转登录页
Handler loginPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const LoginPage();
});

// 跳转注册页
Handler registerPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const RegisterPage();
});

// 跳转通用的资产详情
Handler assetGeneralDtailPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  String? pageTitle = parameters['pageTitle']?.first;
  pageTitle ??= "";
  return AssetGeneralDetail(pageTitle: pageTitle);
});

// 跳转商品详情页面
Handler productDtailPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const ProductDetailPage();
});

// 跳转公告页面
Handler announcementPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const Announcement();
});

// 跳转订单确认页面
Handler orderConfirmPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const OrderConfirmPage();
});

// 跳转订单确认页面
Handler orderIndexPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const OrderIndexPage();
});

// 跳转订单详情页面
Handler orderDetailHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const OrderDetailPage();
});

// 商品分类页面
Handler productClassifyHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const ProductClassifyPage();
});

// 跳转商品分类/搜索列表
Handler productListHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const ProductListPage();
});

// 跳转商品专区
Handler productSpecialAreaHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  String? pageTitle = parameters['pageTitle']?.first;
  pageTitle ??= "";
  return ProductSpecialAreaPage(
    pageTitle: pageTitle,
  );
});

// 跳转收银台页面
Handler cashierPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const OrderCashier();
});

// 跳转我的团队
Handler mineTeamPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineTeam();
});

// 跳转资产金券
Handler assetGoldPageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const AssetGoldDetail();
});

// 跳转总资产
Handler assetPackgePageHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const AssetPackgeDetail();
});

// 跳转修改昵称
Handler mineChangeNicknameHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineChangeNickname();
});

// 跳转修改密码
Handler mineChangePasswordHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  String? pageTitle = parameters['pageTitle']?.first;
  pageTitle ??= "";
  return MineChangePassword(pageTitle: pageTitle);
});

// 跳转账户安全
Handler mineAccountSafetyHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineAccountSafety();
});

// 跳转资产互转
Handler mineAssetTransitionHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineAssetTransition();
});

// 跳转资产兑换
Handler mineAssetExchangeHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineAssetExchange();
});

// 跳转店铺首页
Handler mallHomeHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MallHomePage();
});

// 跳转我的名片
Handler mineShareCardHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineShareCard();
});

// 跳转修改手机
Handler mineChangeMobileHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return MineChangeMobile();
});

// 跳转找回密码
Handler mineFindPasswordHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return MineFindPassword();
});

// 跳转管理收货地址
Handler mineAddressManagerHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineAddressManager();
});

// 跳转添加/修改收货地址
Handler mineAddressEditHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineAddressEdit();
});

// 跳转添加/修改收货地址
Handler mineAddressChooseHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineAddressChoose();
});

// 跳转我的收藏
Handler mineCollectHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineCollectPage();
});

// 跳转到个人中心
Handler mineInfoHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineInfo();
});

// 跳转到设置
Handler mineSettingHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineSetting();
});

// 跳转到关于我们
Handler mineAboutHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  return const MineAbout();
});

// 跳转webView
Handler webViewHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  String? pageTitle = parameters['pageTitle']?.first;
  pageTitle ??= "";
  return WebViewPage(pageTitle: pageTitle);
});

// 跳转到大图浏览
Handler photoPreviewHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  String? defaultImage = parameters['defaultImage']?.first;
  defaultImage ??= '0';
  return PhotoPreview(
    defaultImage: int.parse(defaultImage),
  );
});

//找不到路由
Handler notFoundHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
  print('页面找不到404');
  return null;
});
